/************************************************************
 * Project Name         [Thinking_In_Java]
 * File Name            [Example_05_Manager.java]
 * Creation Date        [17-Jun-2014]
 * 
 * Copyright© ge.y.yang@gmail.com All Rights Reserved
 * 
 * Work hard, play harder, think big and keep fit
 ************************************************************/
package pkg_02_oop;

/**
 * 继承
 * 
 * @author 不落的太阳(Sean Yang)
 * @version 1.0
 * @since JDK 6
 * 
 */
public class Example_05_Manager extends Example_01_Employee {

	private double bonus;

	/**
	 * 构造方法
	 */
	public Example_05_Manager() {
		super();
	}

	/**
	 * 构造方法
	 * 
	 * @param name
	 *            经理的名称
	 * @param salary
	 *            经理的薪水
	 * @param year
	 *            入职年份
	 * @param month
	 *            入职月份
	 * @param day
	 *            入职日期
	 */
	public Example_05_Manager(String name, double salary, int year, int month,
			int day) {
		super(name, salary, year, month, day);
		bonus = 0;
	}

	/**
	 * 获得奖金
	 * 
	 * @return 奖金
	 */
	public double getBonus() {
		return bonus;
	}

	/**
	 * 设置经理的奖金额度
	 * 
	 * @param bonus
	 */
	public void setBonus(double bonus) {
		this.bonus = bonus;
	}

	/**
	 * 获得经理的薪水: 薪水=薪水+奖金
	 * 
	 * @return 经理的薪水
	 */
	@Override
	public double getSalary() {
		// double baseSalary = getSalary()是递归调用
		double baseSalary = super.getSalary();
		double salary = baseSalary + bonus;
		return salary;
	}

	/**
	 * 返回经理的字符串表示
	 * 
	 * @return 经理的字符串表示
	 */
	@Override
	public String toString() {
		return "Id " + this.getId() + "\tname " + this.getName() + "\tsalary "
				+ this.getSalary() + "\thiredate " + this.getHireDate();
	}
}
